#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void lobby()
{
	printf("**********Caculator***********\n");
	printf("*******1.add      2.sub*******\n");
	printf("*******3.div      4.mul*******\n");
	printf("************0.exit************\n");
}

void calc(int (*p)(int, int))
{
	int input = 0;
	int x = 0;
	int y = 0;
	int result = 0;

	printf("Please input two oprands:>");
	scanf("%d %d", &x, &y);

	result = (*p)(x, y);
	printf("result = %d\n", result);
}

int add(int x, int y)
{
	return x + y;
}

int sub(int x, int y)
{
	return x - y;
}

int div(int x, int y)
{
	return x / y;
}

int mul(int x, int y)
{
	return x * y;
}

int main()
{
	int input = 0;
	int x = 0;
	int y = 0;
	int result = 0;
	do
	{
		lobby();
		printf("Please choose :>");
		scanf("%d", &input);

		switch (input)
		{
		case 1:
			calc(add);
			break;

		case 2:
			calc(sub);
			break;

		case 3:
			calc(div);
			break;

		case 4:
			calc(mul);
			break;

		default:
			printf("Invalid input,please choose again\n");
			break;
		}
	} while (input);
}